home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / pccp019.zip / MASTERM.C < prev    next >
C/C++ Source or Header  |  1992-04-28  |  4KB  |  120 lines

  1. #include<stdio.h>
  2. #include<process.h>
  3.  
  4. main(argc, argv)
  5.     int argc;
  6.     char **argv;
  7.     {
  8.     int run;
  9.     char stopbstr[2], fpname[256], c;
  10.     if(!strcmp(getenv("REMOTE"), "YES"))
  11.         {
  12.         printf("You appear to be logged in remotely, judging by the environment\n");
  13.         printf("variable REMOTE, so this is probably a very bad idea.\n");
  14.         printf("Are you sure you want to run MASTERM? (y or n) --> ");
  15.         if(getchar()!='y') /* Note getchar() and not getch()! */
  16.             {
  17.             printf("n\nI didn't think so!\n");
  18.             exit(99);
  19.             }
  20.         else
  21.             printf("y\nOK, you're the boss!\n");
  22.         }
  23.     if((argc!=4)&&(argc!=5))
  24.         {
  25.         printf("USAGE: masterm <port#> <speed> <databits><parity><stopbits> [<emu file>]\n");
  26.         exit(1);
  27.         }
  28.     spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], NULL);
  29.     stopbstr[0]=argv[3][2];
  30.     stopbstr[1]='\0';
  31.     run=1;
  32.     while(run)
  33.         {
  34.         printf("\n     Copyright (C) 1992 Peter Edward Cann, all rights reserved.\n\n");
  35.         printf("     UPLOAD:  (1) Xmodem   (2) Xmodem CRC   (3) Xmodem CRC 1K   (a) ASCII\n\n");
  36.         printf("     DOWNLOAD:  (4) Xmodem   (5) Xmodem CRC 1K Optional\n\n");
  37.         printf("      (t, SPACE or ENTER) Terminal   (d) Terminal with Dribble\n\n");
  38.         printf("                             (q) Quit\n\n             ---> ");
  39.         c=getch();
  40.         printf("%c\n", c);
  41.         switch(c)
  42.             {
  43.             case 'q':
  44.             case 'Q':
  45.                 run=0;
  46.                 break;
  47.             case 't':
  48.             case 'T':
  49.             case ' ':
  50.             case '\r':
  51.                 if(argc==5)
  52.                     spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], NULL);
  53.                 else
  54.                     spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], NULL);
  55.                 break;
  56.             case 'd':
  57.             case 'D':
  58.                 printf("Dribble file pathname? (Blank to cancel)\n --> ");
  59.                 gets(fpname);
  60.                 if(!strlen(fpname))
  61.                     break;
  62.                 if(argc==5)
  63.                     spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], argv[4], fpname, NULL);
  64.                 else
  65.                     spawnlp(P_WAIT, "term", "term", argv[1], argv[2], argv[3], "-", fpname, NULL);
  66.                 break;
  67.             case '1':
  68.                 printf("Source file pathname? (Blank to cancel)\n --> ");
  69.                 gets(fpname);
  70.                 if(!strlen(fpname))
  71.                     break;
  72.                 spawnlp(P_WAIT, "xmodems", "xmodems", argv[1], argv[2], stopbstr, fpname, NULL);
  73.                 putch('\007');
  74.                 break;
  75.             case 'a':
  76.             case 'A':
  77.                 printf("Source file pathname? (Blank to cancel)\n --> ");
  78.                 gets(fpname);
  79.                 if(!strlen(fpname))
  80.                     break;
  81.                 spawnlp(P_WAIT, "asciis", "asciis", argv[1], argv[2], argv[3], fpname, NULL);
  82.                 putch('\007');
  83.                 break;
  84.             case '2':
  85.                 printf("Source file pathname? (Blank to cancel)\n --> ");
  86.                 gets(fpname);
  87.                 if(!strlen(fpname))
  88.                     break;
  89.                 spawnlp(P_WAIT, "xmcrcs", "xmcrcs", argv[1], argv[2], stopbstr, fpname, NULL);
  90.                 putch('\007');
  91.                 break;
  92.             case '3':
  93.                 printf("Source file pathname? (Blank to cancel)\n --> ");
  94.                 gets(fpname);
  95.                 if(!strlen(fpname))
  96.                     break;
  97.                 spawnlp(P_WAIT, "xmcrc1ks", "xmcrc1ks", argv[1], argv[2], stopbstr, fpname, NULL);
  98.                 putch('\007');
  99.                 break;
  100.             case '4':
  101.                 printf("Target file pathname? (Blank to cancel)\n --> ");
  102.                 gets(fpname);
  103.                 if(!strlen(fpname))
  104.                     break;
  105.                 spawnlp(P_WAIT, "xmodemr", "xmodemr", argv[1], argv[2], stopbstr, fpname, NULL);
  106.                 putch('\007');
  107.                 break;
  108.             case '5':
  109.                 printf("Target file pathname? (Blank to cancel)\n --> ");
  110.                 gets(fpname);
  111.                 if(!strlen(fpname))
  112.                     break;
  113.                 spawnlp(P_WAIT, "xmcrc1kr", "xmcrc1kr", argv[1], argv[2], stopbstr, fpname, NULL);
  114.                 putch('\007');
  115.                 break;
  116.             }
  117.         }
  118.  
  119.     }
  120.